<script type="text/javascript">     

$(document).ready(function(){                                 
                         
    function OpenImageManager(trigger){

        mcImageManager.open('','','',
            function(img_path){
                ImageManagerCallback(img_path, trigger);
            },
            { 
				rootpath : '{0}/<?=INSPIRATIONALGALLERY_IMG_FOLDER?>',
				document_base_url : '<?=base_url().UPLOADS_FOLDER.INSPIRATIONALGALLERY_IMG_FOLDER?>',
            	relative_urls : true
			}
        );
    }

    function ImageManagerCallback(img_path, trigger){

        parent = $(trigger).parents(".ImageManager_Widget");
        parent_id = $(parent).attr('id');
        display_path = '<?=base_url().UPLOADS_FOLDER.INSPIRATIONALGALLERY_IMG_FOLDER?>'+img_path;

        $(parent).find("img").attr("src", display_path);
        $(parent).find("input.img_path").val(img_path).change();

    }

    // bind triggers that open the ImageManager
    $(".open_image_manager").live("click", function () {       
        OpenImageManager(this);
        return false;
    });

});       
</script>

<div id="content">

<? if($this->input->post("submit_action") !== FALSE){ ?>
    <div class="response"><?=validation_errors()?></div>                
<? } ?>

    <form action="" method="post" id="portfolio_form">

    <div class="float_block_right">
        <a href="<?=site_url("admin/gallery")?>" class="button cancel">CANCEL</a>
        <input name="submit_action" type="submit" class="button " value="SAVE">  
    </div>


    <h1>Add new image to Gallery</h1>

    <div id="image" class="content_block ImageManager_Widget">
        <img src="<?=base_url().UPLOADS_FOLDER.INSPIRATIONALGALLERY_IMG_FOLDER.set_value('image')?>" style="display:block; max-width:100%" />
        <a class="open_image_manager button" href="#">SELECT IMAGE</a>
        <input type="hidden" name="image" class="img_path" value="<?=set_value('image')?>" />    
    </div>    
               
    <input type="hidden" name="token" value="<?=$token?>" />

    </form>

</div>